# -*- coding:utf-8 -*-
# @author='dapeng',
# @version='1.0.0'
import requests,json
import re
from bs4 import BeautifulSoup
from api import alapi


#superprefix = "https://jx.618g.com/?url="			#速度还可以
#superprefix = "https://jqaaa.com/jx.php?url="  		#速度挺快的
#superprefix = "https://cclme.cn/ckmov/?url="        #微信不报举报，但是速度慢
#superprefix = "https://api.pangujiexi.com/player.php?url="
#superprefix = "https://ejiafarm.com/jx.php?url="
#superprefix = "https://beaacc.com/api.php?url="
#superprefix = "https://api.fastflv.cc/jiexi/?url="
#superprefix = "https://000o.cc/jx/ty.php?url="
#superprefix = "https://api.daidaitv.com/index/?url="    #微信不报举报，但是速度慢
#superprefix = "https://j.88gc.net/jx/?url="
#superprefix = "https://zy.97zyl.com/?url="
#superprefix = "https://yun.odflv.com/?url="
#superprefix = "https://206dy.com/vip.php?url="
#superprefix = "https://014670.cn/jx/ty.php?url="
#superprefix = "https://030e.com/0302/?url="
#superprefix = "https://www.wocao.xyz/index.php?url="
#superprefix = "https://jx.itaoju.top/?url="
superprefix = "https://jx.wlssys.xyz/vip.php?url="  		#高速秒播
#superprefix = "https://api.78sy.cn/?url=" 					#秒播 无广告解析：
#superprefix = "https://vip.52jiexi.top/?url=" 				#腾讯直解 无广告通用：
#superprefix = "https://api.52jiexi.top/?url="
#superprefix = "https://api.steak517.top/?url=" 				#无广告解析： 秒播
#superprefix = "https://vip.bljiex.com/?url="				#BL智能解析：
#superprefix = "https://api.yueliangjx.com/?url="			#无广告
#superprefix = "https://jx.elwtc.com/vip/?url="				#无广告
#superprefix = "https://vip.ikjiexi.top/api/?url=" 			#无广告，速度也还行
#superprefix = "https://www.2ajx.com/vip.php?url=" 			#无广告
#superprefix = "https://api.flvsp.com/?url="
#superprefix = "https://jx.kt111.top/jx/mf/?url="
#superprefix = "https://jx.wslmf.com/?url=" 					#还行就是 不带缓存要拉快进的注意了
#superprefix = "https://api.8bjx.cn/?url=" 					#秒播吧 记忆
#superprefix = "https://z1.m1907.cn/?jx=" 					#小卡
#superprefix = "https://jx.youyitv.com/?url="
#superprefix = "https://www.kpezp.cn/jlexi.php?url=" 		#速度挺快的*还带记忆播放
#superprefix = "https://jx.f41.cc/?url=" 					#速度还可以
#superprefix = "https://vip.mpos.ren/v/?url="				#黑屏
#superprefix = "https://jx.598110.com/index.php?url=" 		#速度还可以
#superprefix = "https://jx.bwcxy.com/?v=" 					#速度还可以
#superprefix = "https://jx.rdhk.net/?v=" 					#速度一般
#superprefix = "https://jx.fo97.cn/?url=" 					#好像不能用
#superprefix = "https://jx.ivito.cn/?url=" 					#一般
#superprefix = "https://api.927jx.com/vip/?url="				#一般般
#superprefix = "https://api.tv920.com/vip/?url="				#很一般
# superprefix = "https://api.lhh.la/vip/?url="
# superprefix = "https://api.sumingys.com/index.php?url=" 	#很一般
# superprefix = "https://cn.bjbanshan.cn/jx.php?url="			#挺快的
# superprefix = "https://jx.mw0.cc/?url="						#挺快的
# superprefix = "https://www.33tn.cn/?url=" 					#挺快的
# superprefix = "http://jx.1ff1.cn/?url=" 					#还行
# superprefix = "https://jx.000180.top/jx/?url=" 				#一般
# superprefix = "https://py.ha12.xyz/sos/index.php?url="
# superprefix = "https://jiexi.380k.com/?url=" 				#挺快的
# superprefix = "https://okjx.cc/?url="
# superprefix = "http://www.662820.com/xnflv/index.php?url="
# superprefix = "http://api.lldyy.net/svip/?url="
# superprefix = "http://www.82190555.com/index/qqvod.php?url="
# superprefix = "http://jiexi.071811.cc/jx2.php?url="
# superprefix = "http://api.wlzhan.com/sudu/?url="
# superprefix = "https://www.myxin.top/jx/api/?url="  			#腾讯直解 缓存挺快的
# superprefix = "https://jiexi.071811.cc/jx.php?url="  			#挺快的
# superprefix = "https://www.1717yun.com/jx/ty.php?url=" 			#速度还可以
# superprefix = "https://cdn.yangju.vip/k/?url=" 					#一般
# superprefix = "https://vip.jaoyun.com/index.php?url="			#还可以
# superprefix = "http://v.nmbaojie.com/mingri/mingri.php?url="	#速度还行
# superprefix = "https://www.ckmov.vip/api.php?url=" 				#挺快的
# superprefix = "http://jx.ejiafarm.com/dy.php?url=" 				#挺快的
# superprefix = "https://jx.dy-jx.com/?url=" 						#打不开
# superprefix = "https://api.927.la/vip/?url="
# superprefix = "https://jiexi.071811.cc/jx2.php?url="
# superprefix = "https://vip.116kan.com/?url=" 						#高清视频 VIP视频解析116kan智能解析：
# superprefix = "https://jx.kingtail.xyz/?url=" 					#kingtail智能解析：
#superprefix = "https://jsap.attakids.com/?url="
# superprefix = "https://api.lnwu.net/?url="
# superprefix = "https://www.91jxs.com/jiexi/?url=" 				#91视频解析：
# superprefix = "https://www.playm3u8.cn/jiexi.php?url=" 			#Playm3u8解析：除了常见VIP视频地址外，还支持解析QQ相册等地址
# superprefix = "https://www.qianyicp.com/jiexi/index.php?url=" 	#千亿解析：蓝光超清解析接口
# superprefix = "https://api.jhys.top/?url="
# superprefix = "https://api.sigujx.com/?url="					#思古视频服务：
# superprefix = "https://www.xymav.com/?url="						#小野马解析：
# superprefix = "https://www.nxflv.com/?url="						#诺讯智能解析：
# superprefix = "https://v.resoumen.com/?url="					#热搜视频：
# superprefix = "https://jx.618g.com/?url="	 					#618G免费解析：测试后不是很清晰
#
#
# superprefix = "http://avip.fun/tv?utm_source=" 				#测试后直接不清晰
# superprefix = "http://api.bbbbbb.me/jx/?url="
# superprefix = "http://www.a305.org/weixin.php?url="
# superprefix = "http://api.91exp.com/svip/?url="
# superprefix = "http://api.bbbbbb.me/ipsign/player.php?v="
# superprefix = "http://api.ledboke.com/vip/?url="
# superprefix = "http://17kyun.com/api.php?url="
# superprefix = "http://vip.qike.ink/?url="
# superprefix = "http://www.47jx.com/?url="
# superprefix = "http://jx.hanximeng.com/vip.php?url="
# superprefix = "http://yun.baiyug.cn/vip/?url="
# superprefix = "http://jx.myxit.cn/vip/?url="
# superprefix = "http://aikan-tv.com/?url="
# superprefix = "http://jiexi.92fz.cn/player/vip.php?url="
# superprefix = "http://api.662820.com/xnflv/index.php?url="
# superprefix = "http://000o.cc/jx/ty.php?url="
# superprefix = "http://qigetv.xyz/tv.php?url="
# superprefix = "http://beaacc.com/api.php?url="
# superprefix = "http://www.asys.vip/jx/?url=" 				#蓝光
# superprefix = "http://api.zncss.com/?url=" 					#高清
# superprefix = "http://api.steak517.top/?url=" 				#无广告解析：
# superprefix = "http://jx.awx88.cn/jiexi/?url=" 				#无广告超清解析：
# superprefix = "http://gongxiangtv.cn/?url="					#弹幕解析：
# superprefix = "http://api.yueliangjx.com/?url=" 			#无广告
# superprefix = "http://www.2ajx.com/vip.php?url=" 			#无广告
# superprefix = "http://api.baiyug.cn/vip/?url="
# superprefix = "http://api.xfsub.com/index.php?url="
# superprefix = "http://player.jidiaose.com/supapi/iframe.php?v="
# superprefix = "http://api.pucms.com/?url="
# superprefix = "http://api.baiyug.cn/vip/index.php?url="
# superprefix = "http://2gty.com/apiurl/yun.php?url="
# superprefix = "http://v.2gty.com/apiurl/yun.php?url="
# superprefix = "http://jx.as19811.cn/jx.php/?url="
# superprefix = "http://jx.sdjnd09.cn/jx.php/?url="
# superprefix = "http://jx.09876as.cn/jx.php/?url="
# superprefix = "http://jx.17ktv.com.cn/jx.php/?url="
# superprefix = "http://jx.ab78a.cn/jx.php/?url="
# superprefix = "http://jx.09877as.cn/jx.php/?url="
# superprefix = "http://jx.yipolo111.cn/jx.php/?url="
# superprefix = "http://jx.908astbb.cn/jx.php/?url="
# superprefix = "http://jx.dlzyrk001.cn/jx.php/?url="
# superprefix = "http://jx.dccmy.org.cn/jx.php/?url="
# superprefix = "http://jx.boctx.cn/jx.php/?url="
# superprefix = "http://jx.hxbte.cn/jx.php/?url="
# superprefix = "http://api.lvcha2017.cn/?url="
# superprefix = "http://kkk.2016ve.cn/kkjx/index.php?url="
# superprefix = "http://mlxztz.com/vip/?url="
# superprefix = "http://www.aktv.men/?url="
# superprefix = "http://jy777.cn/XSD/XSD/?url="
# superprefix = "http://api.visaok.net/?url="
# superprefix = "http://api.greatchina56.com/?url="
# superprefix = "http://jx.618g.com/?url="
# superprefix = "http://api.baiyug.vip/index.php?url="
# superprefix = "http://jx.jfysz.cn/jx.php/?url="
# superprefix = "http://jx.ektao.cn/jx.php/?url="
# superprefix = "http://jx.reclose.cn/jx.php/?url="
# superprefix = "http://jx.iaeec.cn/jx.php/?url="
# superprefix = "http://jx.83y4n7a.cn/jx.php/?url="
# superprefix = "http://jx.cmbzzs.cn/jx.php/?url="
# superprefix = "http://qxkkk.bid/jx/jx.php?url="
# superprefix = "http://www.27v9.cn/index.php?url="
# superprefix = "http://www.ckplayer.tv/kuku/?url="
# superprefix = "http://o8ve.cn/1/?url="
# superprefix = "http://api.xyingyu.com/?url="
# superprefix = "http://jiexi.xueshi.pro?url="
# superprefix = "http://beijixs.cn/?url=" 								#视频高清 VIP视频解析北极XS视频解析：
# superprefix = "http://vip.365tol.top/?url="								#365t在線免費解析觀看系統：
# superprefix = "http://qmaile.com/?url="	 								#全民解析：解析聚合，多线路解析
# superprefix = "http://www.jspoo.com/vip.html?url="	 					#聚神铺vip解析：解析聚合，多线路选择
# superprefix = "http://120.27.155.106/?url="	 							#Yun Parse视频云解析：填视频ID而不是视频网页地址，另支持解析QQ相册等地址
# superprefix = "http://tv.vipsli.com/?url="								#爱看解析：
# superprefix = "http://vip.hktvyb.com/?url="	 							#TVB云播全网VIP视频解析：聚合解析，多线路
# superprefix = "http://www.okjx.cc/ceshi/?url="	 						#OK解析：测试后不太清晰
#
# superprefix = "https://jx.618g.com/?url="			#速度还可以
# superprefix = "https://jqaaa.com/jx.php?url="  		#速度挺快的
# superprefix = "https://cclme.cn/ckmov/?url="
# superprefix = "https://api.pangujiexi.com/player.php?url="
# superprefix = "https://ejiafarm.com/jx.php?url="
# superprefix = "https://beaacc.com/api.php?url="
# superprefix = "https://api.fastflv.cc/jiexi/?url="
# superprefix = "https://000o.cc/jx/ty.php?url="
# superprefix = "https://api.daidaitv.com/index/?url="
# superprefix = "https://j.88gc.net/jx/?url="
# superprefix = "https://zy.97zyl.com/?url="
# superprefix = "https://yun.odflv.com/?url="
# superprefix = "https://api.xiguaimg.com/odflv105/index.php?url="
# superprefix = "https://206dy.com/vip.php?url="
# superprefix = "https://014670.cn/jx/ty.php?url="
# superprefix = "https://030e.com/0302/?url="
# superprefix = "https://www.wocao.xyz/index.php?url="
# superprefix = "https://jx.itaoju.top/?url="
# superprefix = "https://jx.wlssys.xyz/vip.php?url="  		#高速秒播
# superprefix = "https://api.78sy.cn/?url=" 					#秒播 无广告解析：
# superprefix = "https://vip.52jiexi.top/?url=" 				#腾讯直解 无广告通用：
# superprefix = "https://api.52jiexi.top/?url="
# superprefix = "https://jx.lfeifei.cn/?url=" 				#无广告解析：
# superprefix = "https://api.steak517.top/?url=" 				#无广告解析： 秒播
# superprefix = "https://vip.bljiex.com/?url="				#BL智能解析：
# superprefix = "https://api.yueliangjx.com/?url="			#无广告
# superprefix = "https://jx.elwtc.com/vip/?url="				#无广告
# superprefix = "https://vip.ikjiexi.top/api/?url=" 			#无广告，速度也还行
# superprefix = "https://www.2ajx.com/vip.php?url=" 			#无广告
# superprefix = "https://api.flvsp.com/?url="
# superprefix = "https://jx.kt111.top/jx/mf/?url="
# superprefix = "https://jx.wslmf.com/?url=" 					#还行就是 不带缓存要拉快进的注意了
# superprefix = "https://api.8bjx.cn/?url=" 					#秒播吧 记忆
# superprefix = "https://z1.m1907.cn/?jx=" 					#小卡
# superprefix = "https://jx.youyitv.com/?url="
# superprefix = "https://www.kpezp.cn/jlexi.php?url=" 		#速度挺快的*还带记忆播放
# superprefix = "https://jx.f41.cc/?url=" 					#速度还可以
# superprefix = "https://vip.mpos.ren/v/?url="				#黑屏
# superprefix = "https://jx.598110.com/index.php?url=" 		#速度还可以
# superprefix = "https://jx.bwcxy.com/?v=" 					#速度还可以
# superprefix = "https://jx.rdhk.net/?v=" 					#速度一般
# superprefix = "https://jx.fo97.cn/?url=" 					#好像不能用
# superprefix = "https://jx.ivito.cn/?url=" 					#一般
# superprefix = "https://api.927jx.com/vip/?url="				#一般般
# superprefix = "https://api.tv920.com/vip/?url="				#很一般
# superprefix = "https://api.lhh.la/vip/?url="
# superprefix = "https://api.sumingys.com/index.php?url=" 	#很一般
# superprefix = "https://cn.bjbanshan.cn/jx.php?url="			#挺快的
# superprefix = "https://jx.mw0.cc/?url="						#挺快的
# superprefix = "https://www.33tn.cn/?url=" 					#挺快的
# superprefix = "http://jx.1ff1.cn/?url=" 					#还行
# superprefix = "https://jx.000180.top/jx/?url=" 				#一般
# superprefix = "https://py.ha12.xyz/sos/index.php?url="
# superprefix = "https://jiexi.380k.com/?url=" 				#挺快的
# superprefix = "https://okjx.cc/?url="
# superprefix = "http://www.662820.com/xnflv/index.php?url="
# superprefix = "http://api.lldyy.net/svip/?url="
# superprefix = "http://www.82190555.com/index/qqvod.php?url="
# superprefix = "http://jiexi.071811.cc/jx2.php?url="
# superprefix = "http://api.wlzhan.com/sudu/?url="
# superprefix = "https://www.myxin.top/jx/api/?url="  			#腾讯直解 缓存挺快的
# superprefix = "https://jiexi.071811.cc/jx.php?url="  			#挺快的
# superprefix = "https://www.1717yun.com/jx/ty.php?url=" 			#速度还可以
# superprefix = "https://cdn.yangju.vip/k/?url=" 					#一般
# superprefix = "https://vip.jaoyun.com/index.php?url="			#还可以
# superprefix = "http://v.nmbaojie.com/mingri/mingri.php?url="	#速度还行
# superprefix = "https://www.ckmov.vip/api.php?url=" 				#挺快的
# superprefix = "http://jx.ejiafarm.com/dy.php?url=" 				#挺快的
# superprefix = "https://jx.dy-jx.com/?url=" 						#打不开
# superprefix = "https://api.927.la/vip/?url="
# superprefix = "https://jiexi.071811.cc/jx2.php?url="
# superprefix = "https://vip.116kan.com/?url=" 						#高清视频 VIP视频解析116kan智能解析：
# superprefix = "https://jx.kingtail.xyz/?url=" 					#kingtail智能解析：
# superprefix = "https://jsap.attakids.com/?url="
# superprefix = "https://api.lnwu.net/?url="
# superprefix = "https://www.91jxs.com/jiexi/?url=" 				#91视频解析：
# superprefix = "https://www.playm3u8.cn/jiexi.php?url=" 			#Playm3u8解析：除了常见VIP视频地址外，还支持解析QQ相册等地址
#superprefix = "https://www.qianyicp.com/jiexi/index.php?url=" 	#千亿解析：蓝光超清解析接口
# superprefix = "https://api.jhys.top/?url="
# superprefix = "https://api.sigujx.com/?url="					#思古视频服务：
# superprefix = "https://www.xymav.com/?url="						#小野马解析：
# superprefix = "https://www.nxflv.com/?url="						#诺讯智能解析：
# superprefix = "https://v.resoumen.com/?url="					#热搜视频：
# superprefix = "https://jx.618g.com/?url="	 					#618G免费解析：测试后不是很清晰
#
# #http vip视频解析接口
# superprefix = "http://avip.fun/tv?utm_source="				#测试后直接不清晰
# superprefix = "http://api.bbbbbb.me/jx/?url="
# superprefix = "http://www.a305.org/weixin.php?url="
# superprefix = "http://api.91exp.com/svip/?url="
# superprefix = "http://api.bbbbbb.me/ipsign/player.php?v="
# superprefix = "http://api.ledboke.com/vip/?url="
# superprefix = "http://17kyun.com/api.php?url="
# superprefix = "http://vip.qike.ink/?url="
# superprefix = "http://www.47jx.com/?url="
# superprefix = "http://jx.hanximeng.com/vip.php?url="
# superprefix = "http://yun.baiyug.cn/vip/?url="
# superprefix = "http://jx.myxit.cn/vip/?url="
# superprefix = "http://aikan-tv.com/?url="
# superprefix = "http://jiexi.92fz.cn/player/vip.php?url="
# superprefix = "http://api.662820.com/xnflv/index.php?url="
# superprefix = "http://000o.cc/jx/ty.php?url="
# superprefix = "http://qigetv.xyz/tv.php?url="
# superprefix = "http://beaacc.com/api.php?url="
#superprefix = "http://www.asys.vip/jx/?url=" 				#蓝光
#superprefix = "http://api.zncss.com/?url=" 					#高清
#superprefix = "http://api.steak517.top/?url=" 				#无广告解析：
#superprefix = "http://jx.awx88.cn/jiexi/?url=" 				#无广告超清解析：
#superprefix = "http://gongxiangtv.cn/?url="					#弹幕解析：
# superprefix = "http://api.yueliangjx.com/?url=" 			#无广告
# superprefix = "http://www.2ajx.com/vip.php?url=" 			#无广告
# superprefix = "http://api.baiyug.cn/vip/?url="
# superprefix = "http://api.xfsub.com/index.php?url="
# superprefix = "http://player.jidiaose.com/supapi/iframe.php?v="
# superprefix = "http://api.pucms.com/?url="
# superprefix = "http://api.baiyug.cn/vip/index.php?url="
# superprefix = "http://2gty.com/apiurl/yun.php?url="
# superprefix = "http://v.2gty.com/apiurl/yun.php?url="
# superprefix = "http://jx.as19811.cn/jx.php/?url="
# superprefix = "http://jx.sdjnd09.cn/jx.php/?url="
# superprefix = "http://jx.09876as.cn/jx.php/?url="
# superprefix = "http://jx.17ktv.com.cn/jx.php/?url="
# superprefix = "http://jx.ab78a.cn/jx.php/?url="
# superprefix = "http://jx.09877as.cn/jx.php/?url="
# superprefix = "http://jx.yipolo111.cn/jx.php/?url="
# superprefix = "http://jx.908astbb.cn/jx.php/?url="
# superprefix = "http://jx.dlzyrk001.cn/jx.php/?url="
# superprefix = "http://jx.dccmy.org.cn/jx.php/?url="
# superprefix = "http://jx.boctx.cn/jx.php/?url="
# superprefix = "http://jx.hxbte.cn/jx.php/?url="
# superprefix = "http://api.lvcha2017.cn/?url="
# superprefix = "http://kkk.2016ve.cn/kkjx/index.php?url="
# superprefix = "http://mlxztz.com/vip/?url="
# superprefix = "http://www.aktv.men/?url="
# superprefix = "http://jy777.cn/XSD/XSD/?url="
# superprefix = "http://api.visaok.net/?url="
# superprefix = "http://api.greatchina56.com/?url="
# superprefix = "http://jx.618g.com/?url="
# superprefix = "http://api.baiyug.vip/index.php?url="
# superprefix = "http://jx.jfysz.cn/jx.php/?url="
# superprefix = "http://jx.ektao.cn/jx.php/?url="
# superprefix = "http://jx.reclose.cn/jx.php/?url="
# superprefix = "http://jx.iaeec.cn/jx.php/?url="
# superprefix = "http://jx.83y4n7a.cn/jx.php/?url="
# superprefix = "http://jx.cmbzzs.cn/jx.php/?url="
# superprefix = "http://qxkkk.bid/jx/jx.php?url="
# superprefix = "http://www.27v9.cn/index.php?url="
# superprefix = "http://www.ckplayer.tv/kuku/?url="
# superprefix = "http://o8ve.cn/1/?url="
# superprefix = "http://api.xyingyu.com/?url="
# superprefix = "http://jiexi.xueshi.pro?url="
#superprefix = "http://beijixs.cn/?url=" 								#视频高清 VIP视频解析北极XS视频解析：
#superprefix = "http://vip.365tol.top/?url="								#365t在線免費解析觀看系統：
#superprefix = "http://qmaile.com/?url="	 								#全民解析：解析聚合，多线路解析
#superprefix = "http://www.jspoo.com/vip.html?url="	 					#聚神铺vip解析：解析聚合，多线路选择
#superprefix = "http://120.27.155.106/?url="	 							#Yun Parse视频云解析：填视频ID而不是视频网页地址，另支持解析QQ相册等地址
#superprefix = "http://tv.vipsli.com/?url="								#爱看解析：
# superprefix = "http://vip.hktvyb.com/?url="	 							#TVB云播全网VIP视频解析：聚合解析，多线路
# superprefix = "http://www.okjx.cc/ceshi/?url="	 						#OK解析：测试后不太清晰




#爱奇艺电视剧
#电视剧 {电视剧：庆余生：3}
#电影 {电影：哪吒之魔童降世}
def tvs(topic, index):
    if index<1:
        index=1
    tdic = {}
    url = 'https://so.iqiyi.com/so/q_' + topic + '?source=input&sr=686251317514'
    headers = {
        'Access-Control-Allow-Credentials': 'true',
        'Cache-Control': 'max-age=900',
        'Content-Encoding': 'gzip',
        'Content-Language': 'zh-CN',
        'Content-Type': 'text/html; charset=UTF-8',
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36',
        'Referer': 'http://list.iqiyi.com/www/2/-------------11-4-1-iqiyi--.html',
        'Upgrade-Insecure-Requests': '1'
    }
    markup = requests.get(url=url, headers=headers).text
    # 爬取爱奇艺电视剧总网页，解析HTML网页
    soup = BeautifulSoup(markup, 'html5lib')
    # html.parser解析HTML网页
    mdivlists = soup.find_all("div", attrs={"class": "qy-search-result-item vertical-pic"})[0]
    bst = mdivlists.find_all("a", attrs={"class": "album-link"})
    print('========' + topic + '========')
    for item in bst:
        href = re.findall('href="(.*?)"', str(item))
        title = re.findall('title="(.*?)"', str(item))
        tdic[title[0]] = superprefix + href[0]

    return alapi.shorten(tdic.get('第'+str(index)+'集'))


#爱奇艺电影 TODO有问题
def movie(topic):
    tdic = {}
    url = 'https://so.iqiyi.com/so/q_' + topic + '?source=input&sr=686251317514'
    headers = {
        'Access-Control-Allow-Credentials': 'true',
        'Cache-Control': 'max-age=900',
        'Content-Encoding': 'gzip',
        'Content-Language': 'zh-CN',
        'Content-Type': 'text/html; charset=UTF-8',
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36',
        'Referer': 'http://list.iqiyi.com/www/2/-------------11-4-1-iqiyi--.html',
        'Upgrade-Insecure-Requests': '1'
    }
    markup = requests.get(url=url, headers=headers).text
    # 爬取爱奇艺电视剧总网页，解析HTML网页
    soup = BeautifulSoup(markup, 'html5lib')
    # html.parser解析HTML网页
    mdivlists = soup.find_all("a", attrs={"class": "qy-search-result-btn"})[0]
    print('========' + topic + '========')
    href = re.findall('href="(.*?)"', str(mdivlists))
    movurl = superprefix + href[0]
    topic + ': \n' + movurl


# 豆瓣
dbtype = {
    '纪录片': 1,   '传记': 2,    '犯罪': 3,    '历史': 4,
    '动作': 5,    '情色': 6,    '歌舞': 7,    '儿童': 8,
    '悬疑': 10,   '剧情': 11,   '灾难': 12,   '爱情': 13,
    '音乐': 14,   '冒险': 15,   '奇幻': 16,   '科幻': 17,
    '运动': 18,   '惊悚': 19,   '恐怖': 20,   '战争': 22,
    '短片': 23,   '喜剧': 24,   '动画': 25,   '同性': 26,
    '西部': 27,   '家庭': 28,   '武侠': 29,   '古装': 30,
    '黑色电影': 31,
}


def tostring(l):
    out_str = '\n'
    for s in l:
        out_str = out_str + s + '\n'
    return out_str



def totstr(l):
    out_str = ''
    for s in l:
        out_str = out_str + s + ','
    return out_str


#豆瓣电影
def douban(type, index):
    if index<0:
        index = 0
    url = 'https://movie.douban.com/j/chart/top_list'
    params = {
        'type': dbtype.get(type),
        'interval_id': '100:90',
        'action': '',
        'start': 0,
        'limit': 20
    }
    proxies = {'http': '125.110.90.93:9000', 'https': ''}
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36', }
    content = requests.get(url=url, params= params,headers=headers, proxies=proxies).content.decode('utf-8')
    movie_data = json.loads(content)
    data_list = []
    data_list.append('标题：'+movie_data[index].get('title'))
    data_list.append('评分：'+movie_data[index].get('score'))
    data_list.append('区域：'+movie_data[index].get('regions')[0])
    data_list.append('类型：'+totstr(movie_data[index].get('types')))
    data_list.append('地址：'+movie_data[index].get('url'))
    data_list.append('上映：'+movie_data[index].get('release_date'))
    data_list.append('海报：'+movie_data[index].get('cover_url'))
    data_list.append('演员列表：'+totstr(movie_data[index].get('actors')))
    return tostring(data_list)


#豆瓣分类
def dbfl():
    return totstr(dbtype)
